
//functions are used for multipurposes

//1) constructor
// 2) multiple instances
// 3) inheritance
// 4) this

var person = {
    name : 'john',
    age : 30,
    calculateDOB : function(){
        return 2015 - this.age
        //person.age, this.age
    }
};

person.calculateDOB();//
//

function Person(name,age){
    //var this = {};
    this.name = name;//window
    this.age = age;
       // return this;
}

//window
//name
//age
var brian = Person('brian', 30);// undefined

var jDoe = new Person('doe', 30);
var madhu = new Person('madhu',30);//

jDoe.age++;

//
//instance of an object
//
// Cars
// Prototype or sketch or design on paper -- Class
//Object - instance of a class
//

// Madhu's Car -- instance of the original car design
// Mahesh's Car -- instance of the original car design




console.log('jdoe object name: '+ jDoe.name + ' and age is ' + jDoe.age);
console.log('window object name: '+ window.name + ' and age is ' + window.age);

function Person(name, location){
    this.name = name;
    this.location = location;
}

var swathi = new Person('swathi','kansas');

swathi.location

var madhu = {
    name : "madhu",
    location : "kansas"
};

var swathi = {
    name  : "swathi",
    location : "boston"
}

var mahesh = {
    name : "mahesh",
    location : "new york"
}


